<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="umsroot.css">
<TITLE>
Datagram Connection (unix domain)
</TITLE>
</HEAD>
<BODY >
<A HREF="umsroot133.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot129.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc296">21.5</A>&nbsp;&nbsp;Datagram Connection (unix domain)</H2>
This is similar to datagram connection in the internet domain, except that
it is limited to communications between two processes on the same Unix
machine.<BR>
<BR>
Again, like in the internet domain, the connection needs to be established
in both directions if bi-direction communication is required:
<BLOCKQUOTE CLASS="quote">
<PRE CLASS="verbatim">
server:
    % Make a named socket and read two terms from it
    [eclipse 10]: socket(unix, datagram, s), bind(s, '/tmp/sock').

    yes.
    [eclipse 11]: read(s, X), read(s, Y).

process1:
    % Connect a socket to the server and write one term
    [eclipse 32]: socket(unix, datagram, s), connect(s, '/tmp/sock').

    yes.
    [eclipse 33]: printf(s, "%w. %b", message(process1)).

process2:
    % Connect a named socket to the server and write another term
    [eclipse 15]: socket(unix, datagram, s), connect(s, '/tmp/sock'),
        bind(s, '/tmp/socka').

    yes.
    [eclipse 16]: printf(s, "%w. %b", message(process2)).

    yes.
    % And now disconnect the output socket from the server
    [eclipse 17]: connect(s, 0).

    yes.

server:
    % Now the server can read the two terms
    X = message(process1)
    Y = message(process2)
    yes.
    % and it writes one term to the second process on the same socket
    [eclipse 12]: connect(s, '/tmp/socka'),
        printf(s, "%w. %b", message(server)).

process2:
    % 
    [eclipse 18]: read(s, Msg).

    Msg = message(server)
    yes.
</PRE></BLOCKQUOTE>
<HR>
<A HREF="umsroot133.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="umsroot129.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
</BODY>
</HTML>
